#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <string.h>
#include "err_sys.h"


#define BUFFSIZE 150 /* arbitrary size */

int main()
{
  struct sockaddr_in serv;
  char buff[BUFFSIZE];
  int sockfd, n;

  if ((sockfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0)
    err_sys("socket error");

  bzero((char *) &serv, sizeof(serv));
  serv.sin_family = AF_INET;
  serv.sin_addr.s_addr = inet_addr("192.168.1.103");
  serv.sin_port = htons(13);

  if (sendto(sockfd, buff, BUFFSIZE, 0, (struct sockaddr *) &serv, sizeof(serv)) != BUFFSIZE)
      err_sys("sendto error");
  
  if ((n = recvfrom(sockfd, buff, BUFFSIZE, 0, (struct sockaddr *) NULL, (int *) NULL)) < 2)
    err_sys("recvfrom error");
  
  buff[n-2] = 0; /* null terminate */
  printf("%s\n", buff);

  exit(0);
}
